function axios(config){
	const {method="get",url,cancelToken} = config;
	return new Promise((resolve,reject)=>{
		const request = new XMLHttpRequest();
		request.responseType = "json";
		request.open(method,url);
		request.send();
		request.onload = function(){
			resolve({
				config,
				data:request.response,// 响应头
				headers:request.getAllResponseHeaders(),// 响应体
				request,// xhr 实例
				status:request.status,// 状态码
				statusText:request.statusText// 状态码说明
			})
		}
		if(cancelToken){
			cancelToken.cancel.then(value=>{
				// 将request请求取消掉
				request.abort();
			})
		}
		request.onabort = function(){
			reject("取消请求")
		}
	})
}
axios.CancelToken = function(cb){
	this.cancel = new Promise(resolve=>{
		cb(resolve);
	})
}
axios.get = function(url,config={}){
	return this({
		...config,
		url
	})
}